<?xml version="1.0" encoding="UTF-8"?>
<!--
           

        Copyright  1990-2009 Sun Microsystems, Inc. All Rights Reserved.
        DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
        
        This program is free software; you can redistribute it and/or
        modify it under the terms of the GNU General Public License version
        2 only, as published by the Free Software Foundation.
        
        This program is distributed in the hope that it will be useful, but
        WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
        General Public License version 2 for more details (a copy is
        included at /legal/license.txt).
        
        You should have received a copy of the GNU General Public License
        version 2 along with this work; if not, write to the Free Software
        Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
        02110-1301 USA
        
        Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
        Clara, CA 95054 or visit www.sun.com if you need additional
        information or have any questions.
-->
<!--
    This stylesheet generates source code of com.sun.cdc.config.PackageManager
    class. Output code is intended for temporary use only, until real
    PackageManager with capability of enumerating dynamically loaded
    packages is implemented.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- stylesheet parameter: space separated list of JSR initialization classes -->
<xsl:param name="initializers"></xsl:param>
<xsl:output method="text"/>


<xsl:template match="/">
<xsl:text>/*
 *
 *
 * Copyright  1990-2009 Sun Microsystems, Inc. All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 only, as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License version 2 for more details (a copy is
 * included at /legal/license.txt).
 * 
 * You should have received a copy of the GNU General Public License
 * version 2 along with this work; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 * 
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 or visit www.sun.com if you need additional
 * information or have any questions.
 *
 */

/*
 * This file is automatically generated. Do not edit.
 */

package com.sun.cdc.config;

public class PackageManager {
    static final String[] components = {
</xsl:text>

    <!-- process initializers if it isn't empty -->
    <xsl:if test="boolean($initializers)">
        <xsl:call-template name="addClasses">
            <xsl:with-param name="classesList" select="$initializers"/>
        </xsl:call-template>
    </xsl:if>

<xsl:text>    };

    public static void init() throws ClassNotFoundException {
        for (int i = 0; i &lt; components.length; i++) {
            Class.forName(components[i]);
        }
    }
}
</xsl:text>
</xsl:template>

<!-- list the classes as a String[] array -->
<xsl:template name="addClasses">
<!-- template parameter: space separated list of classes -->
<xsl:param name="classesList"/>
<!-- add first class name to the array -->
<xsl:text>        "</xsl:text>
    <xsl:choose>
        <!-- when there is more than one element in the list -->
        <xsl:when test="contains($classesList,' ')">
            <xsl:value-of select="substring-before($classesList,' ')"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$classesList"/>
        </xsl:otherwise>
    </xsl:choose>
<xsl:text>",
</xsl:text>
<!-- and call this template recursively to process the rest of class names -->
    <xsl:if test="contains($classesList,' ')">
        <xsl:call-template name="addClasses">
            <xsl:with-param name="classesList" select="substring-after($classesList,' ')"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>

</xsl:stylesheet>
